﻿using Shop.Model.DB;
using WeDonekRpc.Helper;
using WeDonekRpc.Helper.IdGenerator;
using WeDonekRpc.SqlSugar;

namespace Shop.Repository.lmpl
{
    internal class ShopRepository : ShopBaseRepository<DBShop, long>, IShopRepository
    {
        public ShopRepository (ISqlClientFactory factory) : base(factory)
        {
        }
        public void Add (DBShop shop)
        {
            shop.Id = IdentityHelper.CreateId();
            shop.AddTime = DateTime.Now;
            base.Insert(shop);
        }
        public void UpdateLogo (long id, string logo)
        {
            if (!base.Update(a => a.ShopLogo == logo, a => a.Id == id))
            {
                throw new ErrorException("shop.logo.set.fail");
            }
        }

    }
}
